home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / BSORT.INC < prev    next >
Text File  |  1989-03-01  |  897b  |  41 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * bsort.inc - generic bubble sort
  15.  *
  16.  * #define SORT_COUNT      number of items to sort
  17.  * #define SORT_REVERSED   returns true if %1 > %1+1
  18.  * #define SORT_SWAP       exchange %1 and %1+1
  19.  *
  20.  *)
  21.  
  22. procedure sort;
  23. var
  24.    i: integer;
  25.    swapped: boolean;
  26. begin
  27.    repeat
  28.       swapped := false;
  29.       for i := 1 to SORT_COUNT do
  30.          if SORT_REVERSED(i) then
  31.          begin
  32.             SORT_SWAP(i);
  33.             swapped := true;
  34.          end;
  35.    until not swapped;
  36. end;
  37.  
  38.  
  39.  
  40.  
  41.